/*
 * Copyright (C) 2021 The Chinese Software International Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tonyodev.fetch2;

/**
 * description Status
 *
 * @author liuluming
 * @since 2021-05-20
 */
public enum Status {
    /**
     * Indicates when a download is newly created and not yet queued.
     */
    NONE(0),

    /**
     * Indicates when a newly created download is queued.
     */
    QUEUED(1),

    /**
     * Indicates when a download is currently being downloaded.
     */
    DOWNLOADING(2),

    /**
     * Indicates when a download is paused.
     */
    PAUSED(3),

    /**
     * Indicates when a download is completed.
     */
    COMPLETED(4),

    /**
     * Indicates when a download is cancelled.
     */
    CANCELLED(5),

    /**
     * Indicates when a download has failed.
     */
    FAILED(6),

    /**
     * Indicates when a download has been removed and is no longer managed by Fetch.
     */
    REMOVED(7),

    /**
     * Indicates when a download has been deleted and is no longer managed by Fetch.
     */
    DELETED(8),

    /**
     * Indicates when a download has been Added to Fetch for management.
     */
    ADDED(9);
    int value;

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    Status(int value) {
        this.value = value;
    }

    /**
     * valueOf
     *
     * @param value value
     * @return true
     */
    public static Status valueOf(int value) {
        Status mStatus;
        switch (value) {
            case 0:
                mStatus = Status.NONE;
                break;
            case 1:
                mStatus = Status.QUEUED;
                break;
            case 2:
                mStatus = Status.DOWNLOADING;
                break;
            case 3:
                mStatus = Status.PAUSED;
                break;
            case 4:
                mStatus = Status.COMPLETED;
                break;
            case 5:
                mStatus = Status.CANCELLED;
                break;
            case 6:
                mStatus = Status.FAILED;
                break;
            case 7:
                mStatus = Status.REMOVED;
                break;
            case 8:
                mStatus = Status.DELETED;
                break;
            case 9:
                mStatus = Status.ADDED;
                break;
            default:
                mStatus = Status.NONE;
        }

        return mStatus;
    }
}

